package com.yaorange.certificate.service.impl;

import com.yaorange.certificate.domain.NjtYtjPos;
import com.yaorange.certificate.mapper.NjtYtjPosMapper;
import com.yaorange.certificate.service.NjtYtjPosService;
import com.yaorange.common.core.domain.model.LoginUser;
import com.yaorange.common.utils.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Collections;
import java.util.Date;
import java.util.List;

/**
 * @author coach tam
 * @email 327395128@qq.com
 * @values 坚持灵活 灵活坚持
 * @since 2024/7/9
 */
@Service
public class NjtYtjPosServiceImpl implements NjtYtjPosService {

    @Autowired
    private NjtYtjPosMapper posMapper;

    @Override
    @Transactional(readOnly = true)
    public List<NjtYtjPos> selectNjtYtjPosList(NjtYtjPos njtYtjPos) {
        return posMapper.selectNjtYtjPosList(njtYtjPos);
    }

    @Override
    @Transactional
    public int insertNjtYtjPos(NjtYtjPos njtYtjPos) {
        njtYtjPos.setCreateTime(new Date());
        LoginUser loginUser = SecurityUtils.getLoginUser();
        njtYtjPos.setCreateBy(loginUser.getUsername());
        return posMapper.insertNjtYtjPos(njtYtjPos);
    }

    @Override
    @Transactional
    public int updateNjtYtjPos(NjtYtjPos njtYtjPos) {
        njtYtjPos.setUpdateTime(new Date());
        njtYtjPos.setUpdateBy(SecurityUtils.getLoginUser().getUsername());
        return posMapper.updateNjtYtjPos(njtYtjPos);
    }

    @Override
    @Transactional
    public int batchDeleteNjtYtjPos(Long[] ids) {
        return posMapper.batchDeleteNjtYtjPos(ids);
    }
}
